function populateSelectWithSets(setSelectElement, jsonSets, sortByTitle)
{
	if (setSelectElement == null)
		return;

	while (setSelectElement.length > 0)
		setSelectElement.remove(0);

	var infoOptionElement = document.createElement("option");
	infoOptionElement.text = "Select a set";
	setSelectElement.add(infoOptionElement);

	if (jsonSets == null)
		return;

	var setTitles = new Array();
	var setTitlesToIds = new Array();
	for (i in jsonSets) {
		var jsonSet = jsonSets[i];
		var setTitle = jsonSet.title._content;
		setTitles.push(jsonSet.title._content);
		setTitlesToIds[jsonSet.title._content] = jsonSet.id;
	}

	// addme: sort set titles if needed

	for (i in setTitles) {
		var newOptionElement = document.createElement("option");
		var setTitle = setTitles[i];
		newOptionElement.value = setTitlesToIds[setTitle];
		newOptionElement.text = setTitle;
		setSelect.add(newOptionElement);
	}
}
